package org.ch02.sk.demo06;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;

/**
 * @author XCH
 * @date 2025 - 03 - 24
 */
public class MainTest {
    public static void main(String[] args) {
            try {
                // Introspector.beanInfo获取staffs类信息
                BeanInfo beanInfo = Introspector.getBeanInfo(Staffs.class);
                // 获取staffs类属性信息
                PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
                for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
                    // 获取属性名
                    System.out.println(propertyDescriptor.getName());
                    // 获取属性类型
                    System.out.println(propertyDescriptor.getPropertyType());
                }
            } catch (IntrospectionException e) {
                throw new RuntimeException(e);
            }
    }
}
